home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1995 #5 & #6
/
Amiga Plus CD - 1995 - No. 5 and 6.iso
/
pd
/
netz
/
gethttp
/
gethttp.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1995-08-08
|
4KB
|
151 lines
/*
$VER: GetHTTP 1.5 by Remco van Hooff
Rips http addresses from a file and saves
(adds) them to the AMosaic hotlist.
Comments, improvements, suggestions are welcome.
You can reach me at: NLA 14:101/200.39
AMY 39:153/201.39
FIDO 2:286/407.39
Inet excalibr@igr.nl
Or at Excalibur BBS (+31-10-4187196), just leave
a msg to me (via the leave comment to sysop menu)
*/
/* No need for quotes when using volumes or filenames with spaces. */
/* If used in/from DOpus use the 'No filename quote' option. */
/* change these if needed */
httpfile = 'envarc:mosaic/.mosaic-hotlist-default' /* the hotlist */
copytoenv = 1 /* copy the hotlist to env: for for direct use (0=no, 1=yes) */
ARG file
if (file = '') | (file = '?') then do
say; say 'No input file specified.'
say 'Usage: rx GetHTTP.rexx <file>'; say
exit
end
if ~show('l','rexxreqtools.library') then
if ~addlib('rexxreqtools.library',0,-30,0) then do
say "Couldn't find rexxreqtools.library"
exit
end
options results
dat = date()
parse var dat dagnr maand jaar
dag = left(date('W', date(S), 'S'), 3)
datum = dag maand dagnr time()jaar
saved = 0
open(temp,file,'r')
msg = readch(temp,2097152) /* max size = 2MB, change if more is required */
msg = translate(msg, 'hpt', 'HPT') /* Make 'http' lowercase.*/
check = pos('ttp://', msg)
if check = 0 then do
rtezrequest('No URL found.', '_Ok', 'GetHTTP')
exit
end
close(temp)
if check ~=0 then do
open(temp, file, 'r')
do while ~eof(temp)
msg = readln(temp)
msg = translate(msg, 'hpt', 'HPT')
parse var msg . 'ttp://' httpadres .
if httpadres ~= '' then do
lengte = length(httpadres)
call filter(httpadres, lengte)
vraag = center(' Save this URL? ',lengte2,'-')
httpadres = rtgetstring(httpadres,vraag,'Get HTTP','_Save|_Abort|S_kip')
if rtresult = 1 then do
if ~exists(httpfile) then do
rtezrequest('Hotlist not found!', '_Ok', 'GetHTTP')
exit
end
else do
call open(http,httpfile,'a')
call writeln(http,httpadres||' '||datum)
call addname()
call close(http)
saved = 1
end
end
if rtresult = 2 then do
call copyenvarc()
exit
end
end
end
close(temp)
end
rtezrequest('No more URLs found.', '_Ok', 'GetHTTP')
call copyenvarc()
exit
addname:
do forever
httpname = rtgetstring(,'Enter URL name','Get HTTP','_Ok|_Cancel')
if (rtresult = 1) & (httpname ~= '') then leave
end
call writeln(http,httpname)
return
filter:
adres = arg(1)
lngth = arg(2)
lf = '0a'x
cr = '0d'x
lnfd = pos(lf, adres)
if lnfd ~=0 then do
adres = delstr(adres, lnfd)
end
cret = pos(cr, adres)
if cret ~=0 then do
adres = delstr(adres, cret)
end
/*1.3*/
punt = lastpos('.', adres)
if punt ~=0 then lngth = length(adres)
if (punt = lngth) then do
adres = delstr(adres, punt)
end
haak = lastpos(')', adres)
if haak ~=0 then do
adres = delstr(adres, haak)
end
komma = pos(',', adres)
if komma ~= 0 then do
adres = delstr(adres, komma)
end
quote = pos("'", adres)
if quote ~= 0 then do
adres = delstr(adres, quote)
end
dquote = pos('"', adres)
if dquote ~= 0 then do
adres = delstr(adres, dquote)
end
httpadres = 'http://'||adres
lengte2 = length(httpadres)
return
copyenvarc:
if (copytoenv = 1) & (saved = 1) then do
address command 'copy' httpfile 'env:mosaic'
end
return